<?php
require('../lib/mvc.php');
$app=new mvc('web');
define('HTTP_REFERER',empty($_SERVER['HTTP_REFERER'])?domain:$_SERVER['HTTP_REFERER']);
$session=$app->library('session',array('build'=>false));
$purview=array();
if($session->ISSESS()){
	$role=$session->GVAR('role');
	if(!empty($role)){
		$purview=$session->GVAR('purview');
		$menu=$session->GVAR('menu');
		if(empty($purview)){
			$purview=$app->model('purview')->GPurview(array('where'=>array('role ='=>$role)));
			$session->SVAR('purview',$purview);
		}
		if(empty($menu)){
			$menu=$app->model('menu')->Menutree($purview);
			$session->SVAR('menu',$menu);
		}
		$app->set(array('purview'=>$purview,'menu'=>$menu,'name'=>$session->GVAR('name')));
	}
}
if(!$app->purview($purview)){
	$message=$app->controller('message');
	$message->index(5,domain,'no','您没有权限进行这个操作,5秒后返回上一页.');
	exit();
}
$app->run();
?>